"""mysite1 URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
# 路由模块
from django.contrib import admin
from django.urls import path, re_path
# 从当前目录下导入视图模块views
from . import views

# 路由配置
urlpatterns = [
    path('admin/', admin.site.urls),
    # 配置hello的请求，由函数hello_view响应
    # http://127.0.0.1:8000/hello
    path('hello', views.hello_view),
    path('', views.index_view),
    path('page/1', views.page1_view),
    path('page/2', views.page2_view),
    # 使用转换器接收任意的整数
    path('page/<int:pno>', views.pagen_view),
    path('<int:n1>/<str:op>/<int:n2>', views.calc_view),
    # 带有正则匹配路由配置
    # 传递1个数字，可以1～3位数字
    # http://127.0.0.1:8000/num/x
    re_path(r'^num/(?P<n>\d{1,3})$', views.num_view),
    # http://127.0.0.1:8000/email/xx  验证传递的必须是邮箱格式
    re_path(r'^email/(?P<email>[a-zA-Z]\w{5,17}@[a-zA-Z0-9-]{1,}\.[a-zA-Z]{1,})$', views.email_view)

]


